Title: SQL BT (By-BKK) / 04 Filter Sort
Tags: Obsidian_to_Anki

Q: What SQL keyword removes duplicate rows from query results?
A: DISTINCT

Q: How do you select unique values for a column in SQL?
A: SELECT DISTINCT column FROM table

Q: What clause allows you to sort query results?
A: ORDER BY

Q: How do you sort results in descending order in SQL?
A: ORDER BY column DESC

Q: How do you sort results in ascending order in SQL?
A: ORDER BY column ASC

Q: What clause limits the number of rows returned in SQL?
A: LIMIT

Q: Which clause specifies where to start counting rows for LIMIT in SQL?
A: OFFSET

Q: True or False: DISTINCT removes duplicate rows blindly
A: True

Q: If you want only the first 10 rows of a result, which clause do you use?
A: LIMIT 10

Q: What is the effect of ORDER BY on query results?
A: Sorts the rows alpha-numerically by specified column

Q: How do you get unique Pixar movie directors in A-Z order?
A: SELECT DISTINCT director FROM movies ORDER BY director ASC

Q: Write the query to get the last 4 Pixar movies, newest first.
A: SELECT title FROM movies ORDER BY year DESC LIMIT 4

Q: Which query lists the first 5 Pixar movies alphabetically?
A: SELECT title FROM movies ORDER BY title ASC LIMIT 5

Q: How do you get the next 5 Pixar movies, alphabetically after the first 5?
A: SELECT title FROM movies ORDER BY title ASC LIMIT 5 OFFSET 5

Q: Reverse card: DISTINCT
A: Which SQL keyword removes duplicate rows from the result?

Q: Reverse card: ORDER BY
A: Which clause sorts query results in SQL?

Q: Reverse card: LIMIT and OFFSET
A: Which clauses are used for pagination in SQL queries?

Q: Reverse card: SELECT DISTINCT director FROM movies ORDER BY director ASC
A: What is the SQL query to get unique directors of Pixar movies in alphabetical order?

Q: Reverse card: SELECT title FROM movies ORDER BY year DESC LIMIT 4
A: What is the SQL query to list the last 4 Pixar movies from newest to oldest?

Q: Reverse card: SELECT title FROM movies ORDER BY title ASC LIMIT 5 OFFSET 5
A: Which query fetches the sixth to tenth Pixar movies in alphabetical order?